package cn.wxxyhw.server;

import cn.wxxyhw.Dao.MessageDao;
import cn.wxxyhw.Dao.UserDao;
import cn.wxxyhw.Entity.Message;
import cn.wxxyhw.Util.UnReadMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 消息处理类
 * @Author: 洪稳
 * @Date: 2019/6/10
 */
@Service
public class MessageServer {

    @Autowired
    private UserDao userDao;
    @Autowired
    private MessageDao messageDao;

    /**
     * 查询用户未读的消息
     * @param name
     * @return
     */
    public  List<UnReadMessage> getNoReadMessage(String name) {
        List<UnReadMessage> messages = messageDao.getNoReadMessages(name);
        return messages;
    }

    /**
     * 保存消息
     * @param msg
     */
    public void save(Message msg) {
        messageDao.save(msg);
    }

    /**
     * 查询消息
     * @param friendId
     * @param uid
     * @return
     */
    public List<Message> getNoReadMessageDetail(String friendId, String uid) {
        List<Message> messages = messageDao.getNoReadMessageDetail(friendId,uid);
        return messages;
    }

    /**
     * 查询消息记录
     * @param uid
     * @param myid
     * @return
     */
    public List<Message> getMessage(String uid, String myid) {
        List<Message> messages = messageDao.getMessage(uid,myid);
        return messages;
    }
}
